<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"
    import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>修改場地資料</title>
<script language="JavaScript">
  function formCheck()
  {
     if(document.form1.pid.value == ""){
	      alert("請填寫場地編號");
		  document.form1.pid.focus()
		  return false;
	 }
	 if(document.form1.pname.value == ""){
	      alert("請填寫地點名稱");
		  document.form1.pname.focus()
		  return false;
	 }	 
  }
</script>
</head>
<body>
<% if(session.getAttribute("access") == "y" ){%>
<jsp:useBean id="mydb" scope="page" class="bean.ConDbBean"/> <%//連結資料庫的bean %>
<% 
	  String sql="select * from Place WHERE P_ID='"+request.getParameter("pid")+"'";
	  ResultSet rs=mydb.executeQuery(sql); 
	  rs.next();
	  String pstate=rs.getString("P_STATE");
	  sql="select * from PLACE_CLASS ";
	  ResultSet rs2=mydb.executeQuery(sql);
	  %>
<table width="750" border="0" align="center">
  <tr>
    <td width="30" rowspan="4"><jsp:include page="../frameset/left.jsp" flush="true" ></jsp:include></td>
    <td colspan="2"><jsp:include page="../frameset/top.jsp" flush="true" ></jsp:include></td>
    <td width="40" rowspan="4"><jsp:include page="../frameset/right.jsp" flush="true" ></jsp:include></td>
  </tr>
  <tr>
    <td rowspan="2"><jsp:include page="../frameset/mean.jsp" flush="true" ></jsp:include>

    </td>
    <td height="32"><jsp:include page="../frameset/pfm_mean.jsp" flush="true" ></jsp:include></td>
  </tr>
  <tr>
    <td>
    <table width="400" border="0" align="center">
  <tr>
    <td><form id="form1" name="form1" method="post" action="do_alterPlace.jsp">
	<table width="100%" border="1" align="center">
  <tr>
    <td>場地編號</td>
    <td><input type="hidden" name="oldid" value="<%=rs.getString("P_ID")%>"><input type="text" name="pid" value="<%=rs.getString("P_ID")%>"/></td>
  </tr>
  <tr>
    <td>場地類別</td>
    <td>
        <select name="class">
    <% while(rs2.next()){
    
    	if(rs.getString("P_CLASS").equalsIgnoreCase(rs2.getString("PC_ID"))){%>
    		<option value="<%=rs2.getString("PC_ID")%>" selected="selected"><%=rs2.getString("PC_NAME")%></option>
    	<%
    	
    	}
    	else{
    	%>
    	<option value="<%=rs2.getString("PC_ID")%>"><%=rs2.getString("PC_NAME")%></option>
    	<%
    		}
    }
    %>
  		</select>
    </td>
  </tr>
  <tr>
    <td>地點名稱</td>
    <td><input type="text" name="pname" value="<%=rs.getString("P_NAME")%>"/></td>
  </tr>
  <tr align="center">
    <td colspan="2">系統描述</td>
  </tr>
  <tr>
    <td>可容納人數</td>
    <td><input type="text" name="person" maxlength="10" value="<%=rs.getString("PERSON")%>" />人</td>
  </tr>
  <%
	String pair =new String(rs.getString("AIR").getBytes("iso-8859-1"),"utf-8");
	String pdea=new String(rs.getString("DEAFENING").getBytes("iso-8859-1"),"utf-8");
	String pacou=new String(rs.getString("ACOUSTICS").getBytes("iso-8859-1"),"utf-8");
	String mir=new String(rs.getString("MIR").getBytes("iso-8859-1"),"utf-8");
	String scr=new String(rs.getString("SCREEN").getBytes("iso-8859-1"),"utf-8");
	String pro=new String(rs.getString("PROJECTOR").getBytes("iso-8859-1"),"utf-8");
	String light=new String(rs.getString("LIGHT").getBytes("iso-8859-1"),"utf-8");
	String wire=new String(rs.getString("WIRELESS").getBytes("iso-8859-1"),"utf-8");
	String lcd=new String(rs.getString("LCD").getBytes("iso-8859-1"),"utf-8");
	//out.println(lcd);
    //out.println(rs.getString("AIR"));
    //out.println(rs.getString("DEAFENING"));
    //out.println(rs.getString("ACOUSTICS"));
    //out.println(rs.getString("MIR"));
    //out.println(rs.getString("SCREEN"));
    //out.println(rs.getString("PROJECTOR"));
    //String lcdd=rs.getString("AIR");
    //out.println(lcdd+"-");
    
    //if(lcdd.equalsIgnoreCase("無")){
    //out.println("真的是無");
   // }
    

   %>
  <tr>
    <td>是否有空調</td>
    <td><% 
    if(rs.getString("AIR").equalsIgnoreCase("無")){%>
    	<input name="air" type="radio" value="無" checked="checked" />無
  		<input name="air" type="radio" value="有" />有<% 
    }else if(rs.getString("AIR").equalsIgnoreCase("有")){%>
   		 <input name="air" type="radio" value="無"  />無
  		<input name="air" type="radio" value="有" checked="checked"/>有
    <% }%>
    
  	</td>
  </tr>
  <tr>
    <td>隔音效果</td>
    <td><% 
    if(rs.getString("DEAFENING").equalsIgnoreCase("差  ")){%>
    	<input name="deafening" type="radio" value="差" checked="checked" />差
  		<input name="deafening" type="radio" value="普通" />普通
  		<input name="deafening" type="radio" value="好" />好<%
  		}else if(rs.getString("DEAFENING").equalsIgnoreCase("普通")){%>
  		<input name="deafening" type="radio" value="差"  />差
  		<input name="deafening" type="radio" value="普通" checked="checked"/>普通
  		<input name="deafening" type="radio" value="好" />好
  		<% }else if(rs.getString("DEAFENING").equalsIgnoreCase("好  ")){%>
  		<input name="deafening" type="radio" value="差"  />差
  		<input name="deafening" type="radio" value="普通" />普通
  		<input name="deafening" type="radio" value="好" checked="checked"/>好
  		<% }%>
  	</td>
  </tr>
   <tr>
    <td>音響設備</td>
    <td><% 
    if(rs.getString("ACOUSTICS").equalsIgnoreCase("無")){%>
    	<input name="acoustics" type="radio" value="無" checked="checked" />無
  		<input name="acoustics" type="radio" value="有" />有
  		<% }else if(rs.getString("ACOUSTICS").equalsIgnoreCase("有")){%>
  		<input name="acoustics" type="radio" value="無"  />無
  		<input name="acoustics" type="radio" value="有" checked="checked"/>有
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>麥克風</td>
    <td><% 
    if(rs.getString("MIR").equalsIgnoreCase("無")){%>
    <input name="mir" type="radio" value="無" checked="checked" />無
  		<input name="mir" type="radio" value="有" />有
  		<% }else if(rs.getString("MIR").equalsIgnoreCase("有")){%>
  		<input name="mir" type="radio" value="無"  />無
  		<input name="mir" type="radio" value="有" checked="checked"/>有
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>投影屏幕</td>
    <td><% 
    if(rs.getString("SCREEN").equalsIgnoreCase("無")){%>
    <input name="screen" type="radio" value="無" checked="checked" />無
  		<input name="screen" type="radio" value="有" />有
  		<% }else if(rs.getString("SCREEN").equalsIgnoreCase("有")){%>
  		<input name="screen" type="radio" value="無" />無
  		<input name="screen" type="radio" value="有" checked="checked" />有
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>投影機</td>
    <td><% 
    if(rs.getString("PROJECTOR").equalsIgnoreCase("無")){%>
    <input name="projector" type="radio" value="無" checked="checked" />無
  		<input name="projector" type="radio" value="有" />有
  		<% }else if(rs.getString("PROJECTOR").equalsIgnoreCase("有")){%>
  		<input name="projector" type="radio" value="無" />無
  		<input name="projector" type="radio" value="有" checked="checked" />有
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>燈光效果</td>
    <td><% 
    if(rs.getString("LIGHT").equalsIgnoreCase("白燈  ")){%>
    <input name="light" type="radio" value="白燈" checked="checked" />白燈
  		<input name="light" type="radio" value="黃燈" />黃燈
  		<input name="light" type="radio" value="兩段式" />兩段式
  		<% }else if(rs.getString("LIGHT").equalsIgnoreCase("黃燈  ")){%>
  		<input name="light" type="radio" value="白燈"  />白燈
  		<input name="light" type="radio" value="黃燈" checked="checked"/>黃燈
  		<input name="light" type="radio" value="兩段式" />兩段式
  		<% }else if(rs.getString("LIGHT").equalsIgnoreCase("兩段式")){%>
  		<input name="light" type="radio" value="白燈"  />白燈
  		<input name="light" type="radio" value="黃燈" />黃燈
  		<input name="light" type="radio" value="兩段式" checked="checked"/>兩段式
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>無線上網</td>
    <td><% 
    if(rs.getString("WIRELESS").equalsIgnoreCase("無")){%>
    <input name="wireless" type="radio" value="無" checked="checked" />無
  		<input name="wireless" type="radio" value="有" />有
  		<% }else if(rs.getString("WIRELESS").equalsIgnoreCase("有")){%>
  		<input name="wireless" type="radio" value="無" />無
  		<input name="wireless" type="radio" value="有" checked="checked" />有
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>LCD跑馬燈</td>
    <td><% 
    if(rs.getString("LCD").equalsIgnoreCase("無")){%>
    <input name="lcd" type="radio" value="無" checked="checked"/>無
  		<input name="lcd" type="radio" value="有" />有
  		<% }else if(rs.getString("LCD").equalsIgnoreCase("有")){%>
  		<input name="lcd" type="radio" value="無"  />無
  		<input name="lcd" type="radio" value="有" checked="checked"/>有
  		<% }%>
  	</td>
  </tr>
  <tr>
    <td>狀態</td>
    <td>
    <select name="pstate">
    <option value="00" <% if(pstate.equalsIgnoreCase("00")) out.print("selected");%>>可使用</option>
    <option value="01" <% if(pstate.equalsIgnoreCase("01")) out.print("selected");%>>預借中</option>
    <option value="10" <% if(pstate.equalsIgnoreCase("10")) out.print("selected");%>>借用中</option>
    <option value="11" <% if(pstate.equalsIgnoreCase("11")) out.print("selected");%>>逾期 </option>
    </select>
    </td>
  </tr>
  <tr>
    <td>備註</td>
    <td><textarea name="pps" rows="5" cols="30"><%=rs.getString("PS")%></textarea></td>
  </tr>
   <tr>
    <td colspan="2"><div align="center">
      <input name="重新填寫" type="reset" value="重新填寫" />      
      <input name="" type="submit" value="確定" onClick="return formCheck()"/>
    </div></td>
  </tr>
</table>
    </form>
    </td>
  </tr>
</table>
    </td>
  </tr>
  <tr>
    <td colspan="2"></td>
  </tr>
</table>
<%
  }
  else{
  	response.sendRedirect("../index.jsp"); //若沒有登入則回到index.jsp
  } 
  %>
</body>
</html>